package com.edfu.core.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.edfu.core.coursemgt.service.api.ICourseMgtService;
import com.edfu.core.coursemgt.service.ws.ICourseMgtRESTService;
import com.edfu.core.coursemgt.vo.Course;
import com.edfu.core.coursemgt.vo.CourseOfferingInstance;
import com.edfu.core.coursemgt.vo.Enrollment;
import com.edfu.core.util.Response;

/**
 * 
 * @author sahsharm
 *
 */

@Controller
@RequestMapping("/coursemgt")
public class CourseMgtController{
	
//	@Autowired
//	ICourseMgtService courseMgtService;
//	
//	@RequestMapping(value="/institutes", method=RequestMethod.GET)
//	public String getAddInstitutePage() {
//		return "add_institute";
//	}
//	
//	@RequestMapping(value="/branches", method=RequestMethod.GET)
//	public String getAddBranchPage() {
//		return "add_branch";
//	}
//	
//	@Override
//	@RequestMapping(value="/courses", method=RequestMethod.POST)
//	public @ResponseBody Response addCourse(Course course) {
//		Response r = null ;
//		try {
//			r = courseMgtService.addCourse(course);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//
//	@Override
//	@RequestMapping(value="/courses", method=RequestMethod.PUT)
//	public @ResponseBody Response updateCourse(Course course) {
//		Response r = null ;
//		try {
//			r = courseMgtService.updateCourse(course);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//
//	@Override
//	@RequestMapping(value="/courses/{courseCode}", method=RequestMethod.PUT)
//	public @ResponseBody Response deleteCourse(@PathVariable(value = "courseCode") String courseCode) {
//		Response r = null ;
//		try {
//			r = courseMgtService.deleteCourse(courseCode);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//
//	@Override
//	public @ResponseBody Response addCourseInSemesterForBranch(String courseCode,
//			String branchCode, String semesterCode) {
//		Response r = null ;
//		try {
//			r = courseMgtService.addCourseInSemesterForBranch(courseCode, branchCode, semesterCode);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//
//	@Override
//	public @ResponseBody Response removeCourseFromSemesterForBranch(String courseCode,
//			String semesterCode, String branchCode) {
//		Response r = null ;
//		try {
//			r = courseMgtService.removeCourseFromSemesterForBranch(courseCode, semesterCode, branchCode);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//
//	@Override
//	public @ResponseBody Response removeMember(String batchMemberId, String batchCode) {
//		Response r = null ;
//		try {
//			r = courseMgtService.removeMember(batchMemberId, batchCode);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//
//	@Override
//	public @ResponseBody Response enrollUserToMeeting(Enrollment enrollment) {
//		Response r = null ;
//		try {
//			r = courseMgtService.enrollUserToMeeting(enrollment);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//
//	@Override
//	public @ResponseBody Response removeUserFromMeeting(String userId, String meetingCode) {
//		Response r = null ;
//		try {
//			r = courseMgtService.removeUserFromMeeting(userId, meetingCode);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//
//
//	@Override
//	public @ResponseBody Response associateCourseOfferingToCourse(String courseOfferingCode,
//			String courseCode) {
//		Response r = null ;
//		try {
//			r = courseMgtService.associateCourseOfferingToCourse(courseOfferingCode, courseCode);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//
////	@Override
////	public @ResponseBody Response teachCourseOffering(
////			CourseOfferingInstance courseOfferingInstance) {
////		Response r = null ;
////		try {
////			r = courseMgtService.teachCourseOffering(courseOfferingInstance);
////		}catch ( Exception e ) {
////			r = _getFailureResponse(e);
////		}
////		return r;
////	}
//
//	@Override
//	public @ResponseBody Response assignTeacherToBranch(String userId, String branchCode) {
//		Response r = null ;
//		try {
//			r =  courseMgtService.assignTeacherToBranch(userId, branchCode);
//		}catch ( Exception e ) {
//			r = _getFailureResponse(e);
//		}
//		return r;
//	}
//	
//	@Override
//	public Response assignTeacherToCourse(String userId, String courseCode,
//			String branchCode) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	@Override
//	public Response assignTeacherToCourse(String userId, String courseCode,
//			String semesterCode, String branchCode) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//	
////	@Override
////	public String addContent(String contentAsText, String contentCtxType,
////			String contentContextId, String contentType, String contentId,
////			Map<String, String> properties) {
////		// TODO Auto-generated method stub
////		return null;
////	}
//
////	@Override
////	@RequestMapping(value="/courseofferinginstances", method=RequestMethod.GET)
////	public @ResponseBody List<CourseOfferingInstance> getCourseOfferingInstances(@RequestParam(value="userId") String userId, @RequestParam(value="role") String role) {
////		if (role.equals(Consts.UserRole.AUTHOR.toString())) {
////			return _getCourseOfferingInstancesAuthoredByMe(userId);
////		}else if (role.equals(Consts.UserRole.TEACHER)) {
////			return _getCourseOfferingInstancesTaughtByMe(userId);
////		}else if (role.equals(Consts.UserRole.STUDENT)) {
////			return _getCourseOfferingInstancesTaughtToMe(userId);
////		}else {
////			return null;
////		}
////	}
//	
//	private List<CourseOfferingInstance> _getCourseOfferingInstancesAuthoredByMe(String userId) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//	
//	private List<CourseOfferingInstance> _getCourseOfferingInstancesTaughtByMe(String userId) {
//		List<CourseOfferingInstance> offeringInstList = null ;
//		try {
//			offeringInstList = courseMgtService.getCourseOfferingInstancesCurrentlyTaughtByMe(userId);
//		}catch ( Exception e ) {
//		}
//		return offeringInstList;
//	}
//	
//	private List<CourseOfferingInstance> _getCourseOfferingInstancesTaughtToMe(String userId) {
//		List<CourseOfferingInstance> offeringInstList = null ;
//		try {
//			offeringInstList = courseMgtService.getCourseOfferingInstancesCurrentlyTaughtToMe(userId);
//		}catch ( Exception e ) {
//		}
//		return offeringInstList;
//	}
//	
//	
//	private Response _getFailureResponse(Exception e) {
//		Response response = new Response();
//		response.setSuccessful(false);
//		response.setResponseCode("Internal Application Error.");
//		response.setResponseMessage(e.getMessage());
//		return response;
//	}

}
